'''
Author: wangchao
Date: 2024-08-22 10:58:31
LastEditors: wangchao
LastEditTime: 2024-10-04 15:56:28
FilePath: \JD-RTT-Driver\calibrate.py
Description: 
Copyright (c) 2024 by Bingshan Guardian, All Rights Reserved. 
'''
# 计算SOC的函数
def calculate_SOC(OCV_scaled):
    # 将 OCV 缩小 1000 倍
    OCV = OCV_scaled / 10000.0

    # 使用方程计算SOC
    SOC = (-20671.0 * OCV**4 
           + 107658.0 * OCV**3 
           - 208575.0 * OCV**2 
           + 178399.0 * OCV 
           - 56903.5)
    return SOC

# 示例放大1000倍的电压值
OCV_scaled = 12345
SOC = calculate_SOC(OCV_scaled)

# 输出计算结果
print(f"放大后的 OCV: {OCV_scaled}, 真实 OCV: {OCV_scaled / 10000:.3f}, SOC: {SOC:.2f}")
